Release 10.1A: OpenEdge Development:
Java Open Clients


INPUT-OUTPUT and OUTPUT parameters

Java supports no direct mechanism to return a value from a method using parameters. An application can provide holder object parameters to contain the value you want to return.

Holder classes

For each Java data type that maps to a Progress data type, there is a Holder class. These Holder classes belong to the com.progress.open4gl package and extend the com.progress.open4gl.Holder class, shown in Example 4–1.

Example 4–1: OUTPUT and INPUT-OUTPUT holder class
// Holder Definition
Public class Holder
{
    public Holder();
    public Holder(Object value);
    public void setValue(Object value);
    public Object getValue();
    public boolean isNull();
} 

This class has two constructors, one that does and one that does not set a value for the parameter. For an OUTPUT parameter, you do not need to set a value in the holder object. For an INPUT-OUTPUT parameter, you typically do need to set a value to pass as input in the holder object. You can also set the value using the setValue() method after the holder is created.

For an INPUT-OUTPUT parameter, you can set an input value to the 4GL Unknown value (?) by calling setValue(null) on the holder object. For INPUT-OUTPUT and OUTPUT parameters, the application can find out whether an unknown output value is returned by calling the isNull() method or testing for a null return value from the getValue() method on the holder object.

For each parameter data type extension, the holder class and method names changes as follows:

Syntax
Public class DataTypeNameHolder
{
    public DataTypeNameHolder();
    public DataTypeNameHolder(DataType value);
    public void setDataTypeNameValue(DataType value);
    public Object getDataTypeNameValue();
} 

DataTypeName is an initial upper-case name that closely matches the short intrinsic data type or class name for the value, and DataType is the exact primitave data type or full Java class name (with no changes in letter case).

Table 4–3 shows the 4GL-to-Java mapping of INPUT-OUTPUT and OUTPUT parameters to specific holder classes.

Table 4–3: Progress 4GL-to-Java data type mapping for INPUT-OUTPUT
and OUTPUT parameters  
Progress data type
Java proxy data type
CHARACTER 
com.progress.open4gl.StringHolder 
COM-HANDLE 
com.progress.open4gl.COMHandleHolder 
DATASET 
DATASET-HANDLE1 
com.progress.open4gl.ProDataGraphHolder 
DATE
DATETIME
DATETIME-TZ 
com.progress.open4gl.DateHolder 
DECIMAL 
com.progress.open4gl.BigDecimalHolder 
INTEGER 
com.progress.open4gl.IntHolder 
LOGICAL 
com.progress.open4gl.BooleanHolder 
LONGCHAR 
com.progress.open4gl.StringHolder 
MEMPTR 
com.progress.open4gl.MemptrHolder 
RAW 
com.progress.open4gl.ByteArrayHolder 
RECID 
com.progress.open4gl.LongHolder 
ROWID 
com.progress.open4gl.RowidHolder 
TABLE
TABLE-HANDLE
com.progress.open4gl.ProDataGraphHolder 
  • When mapped as a Java SDO DataGraph.1
TABLE
TABLE-HANDLE
com.progress.open4gl.ResultSetHolder 
  • When mapped as an SQL ResultSet.1
Input holds: java.sql.ResultSet
Output holds: com.progress.open4gl.ProResultSet
WIDGET-HANDLE 
com.progress.open4gl.HandleHolder 
1ProDataSet (DATASET and DATASET-HANDLE) and temp-table (TABLE and TABLE-HANDLE) parameters require special handling, including the mapping of temp-table fields. For more information on ProDataSet and temp-table parameters, see the "Passing temp-tables and ProDataSets" section.

Table 4–4 shows the 4GL array-to-Java mapping of INPUT-OUTPUT and OUTPUT array parameters to specific holder classes.

Table 4–4: Progress 4GL with array-to-Java data-type mapping for INPUT-OUTPUT and OUTPUT array parameters  
Progress 4GL array option
Java proxy data type
CHARACTER 
com.progress.open4gl.StringArrayHolder 
COM-HANDLE 
com.progress.open4gl.COMHandleArrayHolder 
DATE
DATETIME 
DATETIME-TZ 
com.progress.open4gl.DateArrayHolder 
DECIMAL 
com.progress.open4gl.BigDecimalArrayHolder 
INTEGER 
com.progress.open4gl.IntArrayHolder 
LOGICAL 
com.progress.open4gl.BooleanArrayHolder 
LONGCHAR 
com.progress.open4gl.StringArrayHolder 
MEMPTR 
com.progress.open4gl.MemptrArrayHolder 
RAW 
com.progress.open4gl.ByteArrayArrayHolder 
RECID 
com.progress.open4gl.LongArrayHolder 
ROWID 
com.progress.open4gl.RowidArrayHolder 
WIDGET-HANDLE 
com.progress.open4gl.HandleArrayHolder 

Holder class definitions

The holder class definitions for each data type follow the form shown in Example 4–2.

Example 4–2: Holder class definitions 
public class IntHolder extends Holder
{
    public IntHolder();
    public IntHolder(int value);
    public void setIntValue(int value);
    public int getIntValue();
}
/* Note the extra constructor on this one.*/
public class BigDecimalHolder extends Holder
{
    public BigDecimalHolder();
    public BigDecimalHolder(java.math.BigDecimal value);
    public BigDecimalHolder(double);
    public void setBigDecimalValue(BigDecimal value)
    public java.math.BigDecimal getBigDecimalValue();
}
public class StringHolder extends Holder
{
    public StringHolder();
    public StringHolder(java.lang.String value);
    public void setStringValue(java.lang.String value);
    public java.lang.String getStringValue();
}
public class BooleanHolder extends Holder
{
    public BooleanHolder();
    public BooleanHolder (boolean value);
    public void setBooleanValue(boolean value).
    Public boolean getBooleanValue();
} 
public class LongArrayHolder extends Holder
{
    public LongArrayHolder();
    public LongArrayHolder(long[ ] value);
    public LongArrayHolder(long[ ] value);
    public void setLongArrayValue(long[ ] value);
    public void setLongArrayValue(long[ ] value); 
    public Long[ ] getLongArrayValue();
} 
/* Holder classes for other data types follow similar forms */ 


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095